﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using School.Entities;

namespace School.Pages.Teaching.Reports
{
    public partial class ajaxGetCourseTeacher : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            SchoolEntities db = new SchoolEntities();
            Response.ClearContent();
            Response.ContentType = "application/json";
            var id = long.Parse(Request["subject_id"]);
            var teachers = db.Te_Teacher_Subject.Where(x => x.SubjectId == id).Select(x => new { x.Id, Teacher = x.ORG_Stuff_Teacher.ORG_Stuff.FName + " " + x.ORG_Stuff_Teacher.ORG_Stuff.MName + " " + x.ORG_Stuff_Teacher.ORG_Stuff.LName });
            Response.Write("[");
            bool first = true;
            foreach (var t in teachers)
            {
                if (!first) Response.Write(",");
                Response.Write("{'id': '"+t.Id+"', 'name': '"+t.Teacher+"'}");
                first = false;
            }
            Response.Write("]");
            Response.End();
        }
    }
}